package com.example.springbootvue.exception;

import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * 应用特定异常
 * 用于表示业务逻辑中的错误状态
 */
@Getter
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class AppException extends RuntimeException {

    private final HttpStatus status;
    private final String message;

    /**
     * 创建应用异常
     * 
     * @param message 错误消息
     */
    public AppException(String message) {
        this(HttpStatus.BAD_REQUEST, message);
    }

    /**
     * 创建应用异常
     * 
     * @param status  HTTP状态码
     * @param message 错误消息
     */
    public AppException(HttpStatus status, String message) {
        super(message);
        this.status = status;
        this.message = message;
    }

    /**
     * 获取错误消息
     * 
     * @return 错误消息
     */
    @Override
    public String getMessage() {
        return message;
    }
}